/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.nus.dataaccess.dao.reviewtemplate;

import com.nus.constant.ConstantTemplateSection;
import com.nus.dataaccess.dao.base.BaseEntity;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author robin.foe
 */

@Entity
@Table(name="TEMPLATE_SECTION")
public class TemplateSection extends BaseEntity{
    
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
    public Long getId() {return id;}
    public void setId(Long id) {this.id = id;}
    @Override
    public Serializable getPk() {return this.getId();}
    
    @Column(name="SECTION_TYPE", length=1, columnDefinition="CHAR(1)")
    private String sectionType = ConstantTemplateSection.HEADER;
    public String getSectionType() {return sectionType;}
    public void setSectionType(String sectionType) {this.sectionType = sectionType;}
    
    @Column(name="CONTENT", length=500)
    private String content;
    public String getContent() {return content;}
    public void setContent(String content) {this.content = content;}
    
    @Column(name="SEQ_NO")
    private Long seqNo;
    public Long getSeqNo() {return seqNo;}
    public void setSeqNo(Long seqNo) {this.seqNo = seqNo;}
    
    @Column(name="TOTAL_WEIGHT")
    private BigDecimal totalWeight;
    public BigDecimal getTotalWeight() {return totalWeight;}
    public void setTotalWeight(BigDecimal totalWeight) {this.totalWeight = totalWeight;}

    @Column(name="REVIEW_TEMPLATE_ID")
    private Long reviewTemplateId;
    public Long getReviewTemplateId() {return reviewTemplateId;}
    public void setReviewTemplateId(Long reviewTemplateId) {this.reviewTemplateId = reviewTemplateId;}
    
    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="REVIEW_TEMPLATE_ID", referencedColumnName="ID",insertable=false,updatable=false)
    private ReviewTemplate reviewTemplate;
    public ReviewTemplate getReviewTemplate() {return reviewTemplate;}
    public void setReviewTemplate(ReviewTemplate reviewTemplate) {
        this.reviewTemplate = reviewTemplate;
        this.setReviewTemplateId((reviewTemplate == null) ? null : reviewTemplate.getId());
    }
    
    
}
